home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
UTIL
/
Alpha 6.5.sit
/
Tcl
/
UserCode
/
Text Filters
/
Text Munging
/
wordcount
< prev
next >
Wrap
Text File
|
1993-10-19
|
665b
|
23 lines
#!/usr/bin/perl
$/ = ""; # Enable paragraph mode.
$* = 1; # Enable multi-line patterns.
# Now read each paragraph and split into words. Record each
# instance of a word in the %wordcount associative array.
while (<>) {
s/-¥n//g; # Dehyphenate hyphenations.
tr/A-Z/a-z/; # Canonicalize to lower case.
@words = split(/¥W*¥s+¥W*/, $_);
foreach $word (@words) {
$wordcount{$word}++; # Increment the entry.
}
}
# Now print out all the entries in the %wordcount array.
foreach $word (sort keys(%wordcount)) {
printf "%20s %d¥n", $word, $wordcount{$word};
}